home *** CD-ROM | disk | FTP | other *** search
/ HamCall (April 1991) / HAMCALL CD-ROM (Buckmaster)(April 1991).BIN / prgming / ctutor / union1.c < prev    next >
Text File  |  1990-10-14  |  733b  |  36 lines

  1.                                          /* Chapter 11 - Program 5 */
  2. main()
  3. {
  4. union {
  5.    int value;     /* This is the first part of the union */
  6.    struct {
  7.       char first;   /* These two values are the second     */
  8.       char second;
  9.    } half;
  10. } number;
  11.  
  12. long index;
  13.  
  14.    for (index = 12;index < 300000;index += 35231) {
  15.       number.value = index;
  16.       printf("%8x %6x %6x\n",number.value, number.half.first,
  17.               number.half.second);
  18.    }
  19. }
  20.  
  21.  
  22.  
  23. /* Result of execution
  24.  
  25.        c      c      0
  26.     89ab   ffab   ff89
  27.     134a     4a     13
  28.     9ce9   ffe9   ff9c
  29.     2688   ff88     26
  30.     b027     27   ffb0
  31.     39c6   ffc6     39
  32.     c365     65   ffc3
  33.     4d04      4     4d
  34.  
  35. */
  36.